package com.rdc.qingkou.presenter;

import android.util.Log;

import com.rdc.qingkou.contract.UserInfoContract;
import com.rdc.qingkou.entity.ModifyUserInfoResult;
import com.rdc.qingkou.model.UserInfoModel;
import com.rdc.qingkou.model.imodel.OnHttpCallBack;

import java.io.File;


public class UserInfoPresenter implements UserInfoContract.IPresenter {

    private UserInfoContract.IModel mIModel;   //M层
    private UserInfoContract.IView mIView;  //V层

    public UserInfoPresenter(UserInfoContract.IView mIView){
        this.mIView = mIView;
        mIModel = new UserInfoModel();
    }

    @Override
    public void getUserInfo(Integer userId) {

        mIModel.getUserInfo(userId, new OnHttpCallBack<ModifyUserInfoResult>() {
            @Override
            public void onSuccessful(ModifyUserInfoResult modifyUserInfoResult) {
                mIView.showData(modifyUserInfoResult);
            }

            @Override
            public void onFaild(String errorMsg) {
                mIView.showInfo(errorMsg);
            }
        });
    }

    @Override
    public void modifyUserInfo(File photo, int sex, String nickName, String signature, Integer userId) {

        mIModel.modifyUserInfo(photo, sex, nickName, signature, userId, new OnHttpCallBack<ModifyUserInfoResult>() {
            @Override
            public void onSuccessful(ModifyUserInfoResult modifyUserInfoResult) {
//                mIView.showData(modifyUserInfoResult);
                Log.d("UserInfoPresenter","ON SUCCESSFUL");
                mIView.showModifyResult(modifyUserInfoResult);
            }

            @Override
            public void onFaild(String errorMsg) {
                Log.d("UserInfoPresenter","FAILED");
                mIView.showInfo(errorMsg);
            }
        });

    }

//    //RETRY
//    @Override
//    public void takePhoto() {
//
//        mIView.takePhoto(sendModel.getImageUri());
//
//    }
}
